Implementing a bit shift using AND, NOT, ADD [closed]

Posted by fdart17 on Programmers See other posts from Programmers or by fdart17
Published on 2011-03-01T02:00:55Z Indexed on 2011/03/01 7:32 UTC
Read the original article Hit count: 289

Filed under:
|

I'm implementing a 16-bit left bit shift by r bits, and I only have access to AND, NOT and ADD. There are 3 condition codes, negative, zero and positive, which are set when you use any of these operations.
How I went about it was :
(1) And the number with 1000 0000 0000 0000 to set condition codes to positive if the most significant bit is 1.
(2) Add the number with itself. This shifts bits one to the left. (3) If the MSB was 1, add 1 to the result.
(4) Loop threw (1)-(3) r times.

I'm wondering if anyone has any hints to some more efficient methods?
Thanks!

© Programmers or respective owner

Related posts about assembly

Related posts about homework